import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Categoryenum } from './categoryenum';
import { BookComponent } from './book/book.component';
import { Sysconstant } from './sysconstant.enum';
import { User } from './user';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  model = new User();
  isLogin = false;
  categorys: any;
  cts = Categoryenum;
  pageNum = 1;
  size = 10;
  constructor(private httpClient: HttpClient) { }
  ngOnInit() {
    this.init();
  }
  init() {
    this.httpClient.get(Sysconstant.BASE_URL + "/book/category").subscribe(data => {
      this.categorys = data;
    }, err => {
      console.log("error")
    })
  }
  gocategory(category: string) {
    location.href = "/detail/" + category;
  }
  onSubmit() {
      if (this.model.username == 'x' && this.model.password == 'x') {
        this.isLogin = true;
    }
  }
}
